﻿<!--#include file="../inc/common.asp"-->
<!--#include file="utils.asp"-->
<%


dim actionid
actionid=request("actionid")
if "newfolder" = actionid then
	call createFolder(request("foldernew"))
elseif "delfolder"	 = actionid then
	call delFolder(request("folderdel"))
elseif "movefolder"	 = actionid then
	call moveFolder(request("foldermove"), request("foldernew"))
elseif "delfile" = actionid then
	call delFile(request("filedel"))
elseif "movefile" = actionid then
	call moveFile(request("file"),request("filenew"))
end if
%>
<html>
<head>
<link rel="stylesheet" href="../styles.css" type="text/css" />
<script language=javascript>
function newFolder(){
	var theform = document.getElementById("form1");
	var name=prompt("请输入文件夹名：","");
	if (name!=null && name != ""){
		theform.foldernew.value=name;
		theform.actionid.value="newfolder";
		theform.submit();
		theform.newBtn.disabled=true;
	}
}
function renameFolder(foldermove){
	var theform = document.getElementById("form1");
	var name=prompt("请输入文件夹名：",foldermove);
	if (name!=null && name != "" && name != foldermove){
		theform.foldermove.value=foldermove;
		theform.foldernew.value=name;
		theform.actionid.value="movefolder";
		theform.submit();
		theform.newBtn.disabled=true;
	}
}

function renameFile(file){
	var theform = document.getElementById("form1");
	var name=prompt("请输入新文件名：",file);
	if (name!=null && name != "" && name != file){
		theform.file.value=file;
		theform.filenew.value=name;
		theform.actionid.value="movefile";
		theform.submit();
		theform.newBtn.disabled=true;
	}
}

</script>
</head>
<body  >
    <br>
    <table width="700" border="0" align="center"  >
      <tr>
        <td>空间限额：<%=MAX_SIZE%>MB</td>
        <td>已用空间：<%=FormatNumber(used_size/1024,-1,-1)%>KB</td>
        <td>    可用空间：<%=FormatNumber((MAX_SIZE * 1024^2 - used_size)/1024,-1,-1)%>KB</td>
      </tr>
      <tr>
        <td colspan="3">当前文件夹：<%=blogObj.blogTitle%><%=folder%> </td>
      </tr>
    </table>
    <br>
<table align=center width=700 border="1" cellpadding="0" cellspacing="0" bordercolorlight="#888888" bordercolordark="#FFFFFF" ID="Table1">
<tr>
  <td width="26" height="18" align="center">
    <a href="index.asp?folder=<%=server.URLEncode(parentFolder)%>" title="返回上级目录"><img border="0" src="images/upfolder.gif" width="22" height="20"></a>
  </td>
  <td width="162" height="18" align="center">文件(夹)</td>
  <td width="101" align="center">预览</td>
  <td width="108" height="18" align="center">大小</td>
  <td width="125" height="18" align="center">创建(上传)日期</td>
  <td height="18" colspan="2" align="center">管理</td>
</tr>
<%
	dim fso
	set fso = createobject("Scripting.FileSystemObject")

	dim  curFolder, folders, subfolder
	set curFolder = fso.getfolder(realPath)
	set folders=curFolder.subfolders
	dim subfolderURL
    for each subfolder in folders
%>
<tr valign="middle">
  <td height="18" colspan="2" align="left">
    <a  href=index.asp?folder=<%=server.URLEncode(folder & "/" & subfolder.name)%>><img border="0" src="images/folder1.gif" width="20" height="20"> <%=subfolder.name%></a></td>
  <td width="101" align="center">&nbsp;</td>
  <td width="108" height="18" align="center">
<% 
        if subfolder.size>0 then
            response.write  FormatNumber(round(subfolder.size/1024,2),-1,-1)
        else
            response.write "0"
        end if
%> KB
  </td>
  <td width="125" height="18" align="center"><%=subfolder.DateCreated%></td>
  <td width="82" height="18" align="center">
    <a href=index.asp?actionid=delfolder&folder=<%=server.URLEncode(folder)%>&folderdel=<%=server.URLEncode(subfolder.name)%> onclick="return window.confirm('真的要删除吗？\n\n删除后无法恢复！')" title="删除此文件夹">删除</a>
  </td>
  <td width="80" height="18" align="center"><a  href=# onclick='renameFolder("<%=subfolder.name%>")' >更名</a></td>
  </tr>
<%
    next
    Set folders = nothing
	
	dim files, file

    Set files=curFolder.files
	

	dim totalCount,  start,  count, i, totalPage
	
	totalCount = files.count
	
	start = request("start")
	if start<>"" then
		start = clng(start)
		if start<0 then
			start=0 
		end if
	else
		start=0    
	end if
	
	count = NF_PAGE_SIZE
	if count>totalCount then
		count = totalCount
	end if
	
	totalPage = (totalCount + NF_PAGE_SIZE -1) \ NF_PAGE_SIZE
	
	sub writePage
		response.write("页码:&nbsp;")
		
		for i=1 to totalPage 
			if start<>(i-1)*NF_PAGE_SIZE then
		%>
		<a href="index.asp?folder=<%=server.URLEncode(folder)%>&start=<%=(i-1)*NF_PAGE_SIZE%>"><%=i%></a>&nbsp;
		<%
			else
				response.write(i&"&nbsp;")
			end if
		next
	end sub
	'call writePage
		
    for each file in files
		if i > start+count-1 then
			exit for
		end if
		if i>=start then
%>
  <tr valign="middle">
    <td height="19" colspan="2" align="left">
      <img src="images/<%=getFileIcon(file)%>" width="18" height="19"> <a target="_blank" href="<%=path &"/"& file.name%>" title="查看此文件"><%=file.name%></a>
    </td>
    <td width="101" align="center">
	<%
		if getFileType(file) = "gif" or getFileType(file) = "jpg" or getFileType(file) = "png" or getFileType(file) = "bmp"  then
	%>
	<a target="_blank" href="<%= path &"/"& file.name%>" title="查看原图"><img src="<%=path &"/"& file.name%>" width=60 height=60 border="0" align="middle"></a>
	<%
		end if
	%>
	&nbsp;</td>
    <td width="108" height="19" align="center">
<% 
        if file.size>0 then
            response.write  FormatNumber(round(file.size/1024,2),-1,-1) 
        else
            response.write "0"
        end if
%> KB
    </td>
    <td width="125" height="19" align="center"><%=file.DateCreated%></td>
    <td width="82" height="19" align="center"><a  href=index.asp?actionid=delfile&folder=<%=server.URLEncode(folder)%>&filedel=<%=server.URLEncode(file.name)%> onclick="return window.confirm('真的要删除吗？\n\n删除后无法恢复！');" title="删除此文件">删除</a></td>
    <td width="80" height="19" align="center"><a  href=# onclick='renameFile("<%=file.name%>")' title="更改现有文件的名称">更名</a></td>
  </tr>
<%
		end if
		i = i+1
    next

%>
</table>
<p align=center><% writePage %></p>
<form name=form1 id=form1 action="index.asp" method="get">
<input type=hidden name=actionid value="newfolder">
<input type=hidden name=folder value="<%=folder%>">
<input type=hidden name=foldermove value="">
<input type=hidden name=foldernew value="">
<input type=hidden name=file value="">
<input type=hidden name=filenew value="">

<p align=center>
<input type=button name="newBtn" value="新建文件夹" onclick="newFolder()">
<input type=button name="upBtn" value="返回上级目录" onclick="document.location='index.asp?folder=<%=server.URLEncode(parentFolder)%>'">
<input type=button name="closeBtn" value=" 关闭 " onclick="window.close()">
</p>
</form>

<%

	if used_size >= (MAX_SIZE * 1024^2) then
		 'response.write "现在占用空间:"& FormatNumber(used_size/1024,-1,-1) & " KB  总空间 :"& MAX_SIZE * 1024 &" KB  你空间己满!请整理你的资料！" 
	else
%>
<form name="form2" id=form2 method="post" action="upload.asp?blog_id=<%=blogObj.blogId%>&cat_id=null&folder=<%=server.URLEncode(folder)%>" enctype="multipart/form-data" >
<table align=center width="80%" cellpadding="0" cellspacing="0" border="0"  >
    <tr align="center" valign="middle"> 
      <td id="upid" > 上传文件：
        <input type="file" name="file1"  value="" size="20">
        <input type="button" name="submitBtn" value="开始上传" class="bt" onClick="this.form.submit();this.disabled=true">
      </td>
    </tr>
</table>
</form>
</html>
<%
	end if


    set files = nothing
    set curFolder = nothing
    set fso = nothing
%>
<!--#include file="../inc/end.asp"-->